package top.dancun.easstudent.controller;

import java.util.Arrays;
import java.util.Map;
import java.util.Objects;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import top.dancun.common.utils.DataUtils;
import top.dancun.easstudent.entity.DormitoryArrangementEntity;
import top.dancun.easstudent.entity.EmploymentDestinationEntity;
import top.dancun.easstudent.entity.StudentEntity;
import top.dancun.easstudent.service.EmploymentDestinationService;
import top.dancun.common.utils.PageUtils;
import top.dancun.common.utils.R;
import top.dancun.easstudent.service.StudentService;


/**
 * 就业去向
 *
 * @author dancun
 * @email message@dancun.top
 * @date 2022-11-05 10:15:04
 */
@RestController
@RequestMapping("/ed")
public class EmploymentDestinationController extends AbstractController{
    @Autowired
    private EmploymentDestinationService employmentDestinationService;



    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("easstudent:ed:list")
    public R list(@RequestBody Map<String, Object> params){
        Map<String ,String > data = DataUtils.mapAddNoEmpty(params, EmploymentDestinationEntity.class);
        PageUtils page = employmentDestinationService.queryPage(params,data);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("easstudent:ed:info")
    public R info(@PathVariable("id") Long id){
		EmploymentDestinationEntity employmentDestination = employmentDestinationService.getById(id);
        return R.ok().put("ed", employmentDestination);
    }

    /**
     * 信息
     */
    @RequestMapping("/getusered")
    public R getUserED(){
        EmploymentDestinationEntity employmentDestination = employmentDestinationService.getED(getUserId());

        return R.ok().put("ed", employmentDestination);
    }

    /**
     * 就业去向登记
     */
    @RequestMapping("/save")
    public R save(@RequestBody EmploymentDestinationEntity ed){
        String userId = getUserId();
        ed.setStudentId(userId);
		employmentDestinationService.save(ed);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("easstudent:ed:update")
    public R update(@RequestBody EmploymentDestinationEntity ed){
		employmentDestinationService.updateById(ed);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("easstudent:ed:delete")
    public R delete(@RequestBody Long[] ids){
		employmentDestinationService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
